using System;

namespace ApiConceptsFramework.FluentApi
{
	/// <summary>
	/// Formatting options for the output of ApiEvaluator.
	/// </summary>
	public enum EvaluatorOutputFormat
	{
		/// <summary>
		/// Formats the output for the console (fixed spacing)
		/// </summary>
		Console,

		/// <summary>
		/// Formats the output for use in a latex table
		/// </summary>
		LatexTable,

		/// <summary>
		/// Formats the output for a table in the codeplex wiki
		/// </summary>
		CodeplexWiki
	}

	/// <summary>
	/// Output format string definitions for the OutputFormat enum.
	/// </summary>
	public static class EvaluatorOutputFormatStrings
	{
		private const string ConsoleLineFormat = "{0,6:0.0}  {1,6:0.0}  {2,8:0.0}  {3,-15}  {4,6}  {5,12}  {6}";
		private const string ConsoleResultFormat = "Total -> {0:0.0}";
		private const string LatexTableLineFormat = "{0:0.0} & {1:0.0} & {2:0.0} & {3} & {4} & {5} & {6}\\\\";
		private const string LatexTableResultFormat = "\\hline\\noalign{{\\smallskip}}\n &  & \\textbf{{{0:0.0}}} & \\textbf{{Overall}}\\\\";
		private const string CodeplexWikiTitleFormat = "|| {0:0.0} || {1:0.0} || {2:0.0} || {3} || {4} || {5} || {6} ||";
		private const string CodeplexWikiLineFormat = "| {0:0.0} | {1:0.0} | {2:0.0} | {3} | {4} | {5} | {6} |";
		private const string CodeplexWikiResultFormat = "||  ||  || {0:0.0} || Overall || || || ||";

		/// <summary>
		/// Gets the title output format string for the specified output format.
		/// </summary>
		/// <param name="format">The output format.</param>
		/// <returns>The fitting format string.</returns>
		public static string GetTitleFormat(this EvaluatorOutputFormat format)
		{
			switch (format)
			{
				case EvaluatorOutputFormat.Console:
					return ConsoleLineFormat;
				case EvaluatorOutputFormat.LatexTable:
					return LatexTableLineFormat;
				case EvaluatorOutputFormat.CodeplexWiki:
					return CodeplexWikiTitleFormat;
				default:
					throw new ArgumentOutOfRangeException("format");
			}
		}

		/// <summary>
		/// Gets the line output format string for the specified output format.
		/// </summary>
		/// <param name="format">The output format.</param>
		/// <returns>The fitting format string.</returns>
		public static string GetLineFormat(this EvaluatorOutputFormat format)
		{
			switch (format)
			{
				case EvaluatorOutputFormat.Console:
					return ConsoleLineFormat;
				case EvaluatorOutputFormat.LatexTable:
					return LatexTableLineFormat;
				case EvaluatorOutputFormat.CodeplexWiki:
					return CodeplexWikiLineFormat;
				default:
					throw new ArgumentOutOfRangeException("format");
			}
		}

		/// <summary>
		/// Gets the result output format string for the specified output format.
		/// </summary>
		/// <param name="format">The output format.</param>
		/// <returns>The fitting format string.</returns>
		public static string GetResultFormat(this EvaluatorOutputFormat format)
		{
			switch (format)
			{
				case EvaluatorOutputFormat.Console:
					return ConsoleResultFormat;
				case EvaluatorOutputFormat.LatexTable:
					return LatexTableResultFormat;
				case EvaluatorOutputFormat.CodeplexWiki:
					return CodeplexWikiResultFormat;
				default:
					throw new ArgumentOutOfRangeException("format");
			}
		}
	}
}